<!DOCTYPE html>
<#assign ctx=Session.basePath>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>服务点审核</title>
    <script>
        var shipid = '<#if shipid??>${shipid}<#else></#if>';
        var company =  '<#if company??>${company}<#else></#if>';
    </script>
    <link href="${ctx}/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="${ctx}/easyui/themes/icon.css" rel="stylesheet" />
    <link href="${ctx}/inspiniain/font-awesome/css/font-awesome.css" rel="stylesheet">
    <script src="${ctx}/js/jquery-1.12.2.min.js"></script>
    <script src="${ctx}/lib/jquery.form.js"></script>
    <script src="${ctx}/easyui/jquery.easyui.min.js"></script>
    <script src="${ctx}/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="${ctx}/pagination/js/layer/layer.js"></script>


</head>
<body>

<div id="tb" style="padding:5px;height:auto">
    <div>
        <input id="title" class="easyui-text" style="width: 200px" placeholder="请输入名称或关键字">
        <a href="#" class="easyui-linkbutton btn-search" iconCls="icon-search" style="width: 80px;">查找</a>
    </div>
</div>

<table id="dg"
       data-options="rownumbers:true,singleSelect:true,pagination:true,url:'${ctx}/manage/map/server-point/ajax/data/page/list',method:'post',toolbar:'#tb',nowrap:false">
    <thead>
    <tr>
        <th data-options="field:'name',width:100">名称</th>
        <th data-options="field:'position',width:120">经纬度</th>
        <th data-options="field:'serverType',width:60">服务类型</th>
        <th data-options="field:'message',width:150">内容</th>
        <th data-options="field:'keyword',width:90">关键字</th>
        <th data-options="field:'status',width:40">状态</th>
        <th data-options="field:'chk',width:60,align:'center'">操作</th>
    </tr>
    </thead>
</table>
<script type="text/javascript">
    function loadAll() {
        var pager = $('#dg').datagrid({
            fitColumns: true,
            fit: true,
            loadFilter: function (data) {
                // alert(data);
                if (data != null && data.rows != null) {
                    for (var i = 0; i < data.rows.length; i++) {
                        var record = data.rows[i];
                        var status = "";
                        var chk="";
                        var position=record.wkt.substring(6,record.wkt.length-1).replace(" ",",");
                        if(record.status == "0"){
                            status = "待审核";
                            chk = "<a href='#' onclick='chkServer(\"" + record.id + "\")'>通过</a>&nbsp;" +
                                    "<a href='#' onclick='chkServer1(\"" + record.id +"\")'>驳回</a>&nbsp;" +
                                    "<a href='#' onclick='locationMap(\"" + record.id +"\",\"" + record.message +"\")'>定位</a>";
                        }else if(record.status == "1"){
                            status = "已审核";
                            chk = "<a href='#' onclick='locationMap(\"" + record.id +"\",\"" + record.message +"\")'>定位</a>";
                        }
                        record.status = status;
                        record.chk = chk;
                        record.position=position;
                    }
                }
                return data;
            }
        })
    };	// get the pager of datagrid
    $(function () {
        loadAll();
        $(".btn-search").click(function () {
            $('#dg').datagrid("load",{
                key : $("#title").val()
            })
        })
    })
    function chkServer(id){
        layer.confirm('是否确认通过？', {
            btn: ['确认','取消'] //按钮
        }, function(){
            $.ajax({
                url:'${ctx}/manage/map/server-point/update',
                data:{id:id,status:'1'},
                success: function (data) {
                    if(data){
                        layer.msg("审核成功")
                        loadAll();
                    }
                }
            });
        }, function(){
        });

    }
    function chkServer1(id){
        layer.confirm('是否确认驳回？', {
            btn: ['确认','取消'] //按钮
        }, function(){
            $.ajax({
                url:'${ctx}/manage/map/server-point/update',
                data:{id:id,status:'2'},
                success: function (data) {
                    if(data){
                        layer.msg("操作成功")
                        loadAll();
                    }
                }
            });
        }, function(){
        });
    }


    function locationMap(id,message) {
        window.parent.locServer(id,'server',message)
    }
</script>

</body>
</html>